package practice;

import java.util.ArrayList;

/*
题目：给一个不多于5位的正整数，要求：一、求它是几位数，二、逆序打印出各位数字。
 */
public class practice24 {

    public static void main(String[] args) {
        System.out.println(getCount(234));
        reserveNumber(50831);
    }
    public static int getCount(int num){
        int count = 1;
        while(num/10 != 0) {
            count++;
            num /= 10;
        }
        return count;
    }
    public static void reserveNumber(int num){
        ArrayList<Integer> list = new ArrayList<>();
        while (num / 10 != 0){
            list.add(num % 10);
            num /= 10;
        }
        list.add(num);
        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i));
        }
    }

}
